package com.jin.webvideo.util.sys;

import com.jin.webvideo.base.SpringBeanGetter;
import com.jin.webvideo.mapper.UtilMapper;

import java.util.List;
import java.util.Map;

public class SqlUtil {
    public static final List<Map<String, Object>> list(String sql) {
        UtilMapper mapper = SpringBeanGetter.getBean(UtilMapper.class);
        return mapper.selectList(sql);
    }
    public static final Map<String, Object> select(String sql) {
        UtilMapper mapper = SpringBeanGetter.getBean(UtilMapper.class);
        return mapper.select(sql);
    }
    public static final int update(String sql) {
        UtilMapper mapper = SpringBeanGetter.getBean(UtilMapper.class);
        return mapper.update(sql);
    }

    public static final boolean arrayContain(String template, String val) {
        if (null == val || template == null) {
            return false;
        }
        return template.indexOf(arrayKay(val)) != -1;
    }

    public static final String arrayKay(String val) {
        return String.format("|%s|", val);
    }
}
